import { defineStore } from 'pinia'

export const useTableDataStore = defineStore({
  id: 'tableData',
  state: () => {
    return {
      currentTableData: [],
      faultDataList: [
        [
          { faultNo: 1, faultName: '台区A相过压', faultParm: 0 },
          { faultNo: 2, faultName: '台区A相失压', faultParm: 0 },
          { faultNo: 3, faultName: '台区B相过压', faultParm: 0 },
          { faultNo: 4, faultName: '台区B相失压', faultParm: 0 },
          { faultNo: 5, faultName: '台区C相过压', faultParm: 0 },
          { faultNo: 6, faultName: '台区C相失压', faultParm: 0 },
          { faultNo: 7, faultName: '台区A相过流', faultParm: 0 },
          { faultNo: 8, faultName: '台区B相过流', faultParm: 0 },
          { faultNo: 9, faultName: '台区A相断相', faultParm: 0 },
          { faultNo: 10, faultName: '台区B相断相', faultParm: 0 },
          { faultNo: 11, faultName: '台区C相断相', faultParm: 0 },
          { faultNo: 12, faultName: '台区C相过流', faultParm: 0 },
          { faultNo: 13, faultName: '设备A相过压', faultParm: 0 },
          { faultNo: 14, faultName: '设备A相失压', faultParm: 0 },
          { faultNo: 15, faultName: '设备B相过压', faultParm: 0 },
          { faultNo: 16, faultName: '设备B相失压', faultParm: 0 },
          { faultNo: 17, faultName: '设备C相过压', faultParm: 0 },
          { faultNo: 18, faultName: '设备C相失压', faultParm: 0 },
          { faultNo: 19, faultName: '设备A相断相', faultParm: 0 },
          { faultNo: 20, faultName: '设备B相断相', faultParm: 0 },
          { faultNo: 21, faultName: '设备C相断相', faultParm: 0 },
          { faultNo: 22, faultName: '设备电压错相序ACB', faultParm: 0 },
          { faultNo: 23, faultName: '设备电压错相序BAC', faultParm: 0 },
          { faultNo: 24, faultName: '设备电压错相序BCA', faultParm: 0 },
          { faultNo: 25, faultName: '设备电流错相序ACB', faultParm: 0 },
          { faultNo: 26, faultName: '设备电流错相序CBA', faultParm: 0 },
          { faultNo: 27, faultName: '设备电流错相序BCA', faultParm: 0 },
          { faultNo: 28, faultName: '设备A相失流(开路)', faultParm: 0 },
          { faultNo: 29, faultName: '设备B相失流(开路)', faultParm: 0 },
          { faultNo: 30, faultName: '设备C相失流(开路)', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 2, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 3, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 4, faultName: 'A相失流', faultParm: 0 },
          { faultNo: 5, faultName: 'B相失流', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 2, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 3, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 4, faultName: 'A相失流', faultParm: 0 },
          { faultNo: 5, faultName: 'B相失流', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相过压', faultParm: 0 },
          { faultNo: 2, faultName: 'A相失压', faultParm: 0 },
          { faultNo: 3, faultName: 'B相过压', faultParm: 0 },
          { faultNo: 4, faultName: 'B相失压', faultParm: 0 },
          { faultNo: 5, faultName: 'C相过压', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失压', faultParm: 0 },
          { faultNo: 7, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 8, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 9, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 10, faultName: 'A相过流', faultParm: 0 },
          { faultNo: 11, faultName: 'B相过流', faultParm: 0 },
          { faultNo: 12, faultName: 'C相过流', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 2, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 3, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 4, faultName: 'A相失流', faultParm: 0 },
          { faultNo: 5, faultName: 'B相失流', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 2, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 3, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 4, faultName: 'A相失流', faultParm: 0 },
          { faultNo: 5, faultName: 'B相失流', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 2, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 3, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 4, faultName: 'A相失流', faultParm: 0 },
          { faultNo: 5, faultName: 'B相失流', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 2, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 3, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 4, faultName: 'A相失流', faultParm: 0 },
          { faultNo: 5, faultName: 'B相失流', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: 'A相过压', faultParm: 0 },
          { faultNo: 2, faultName: 'A相失压', faultParm: 0 },
          { faultNo: 3, faultName: 'B相过压', faultParm: 0 },
          { faultNo: 4, faultName: 'B相失压', faultParm: 0 },
          { faultNo: 5, faultName: 'C相过压', faultParm: 0 },
          { faultNo: 6, faultName: 'C相失压', faultParm: 0 },
          { faultNo: 7, faultName: 'A相断相', faultParm: 0 },
          { faultNo: 8, faultName: 'B相断相', faultParm: 0 },
          { faultNo: 9, faultName: 'C相断相', faultParm: 0 },
          { faultNo: 10, faultName: 'A相过流', faultParm: 0 },
          { faultNo: 11, faultName: 'B相过流', faultParm: 0 },
          { faultNo: 12, faultName: 'C相过流', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: '断相', faultParm: 0 },
          { faultNo: 4, faultName: '失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: '断相', faultParm: 0 },
          { faultNo: 4, faultName: '失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: '断相', faultParm: 0 },
          { faultNo: 4, faultName: '失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
        [
          { faultNo: 1, faultName: '断相', faultParm: 0 },
          { faultNo: 4, faultName: '失流', faultParm: 0 },
          { faultNo: 7, faultName: '三相不平衡', faultParm: 0 },
          { faultNo: 8, faultName: '功率因数超前', faultParm: 0 },
          { faultNo: 9, faultName: '功率因数滞后', faultParm: 0 },
        ],
      ],
      selectFault: null,
      faultChangNum: 0,
      testTableData: [
        {
          testName: 1,
          testDate: '2022-09-06',
          jobGrade: '初级',
        },
      ],
      testChangeNum: 0,
      currentTestTableRow: null,
      faultTableData: [],
      currentFaultTableRow: null,
      testFaultTableData: [],
      powerTableData: [
        {
          name: '电压源',
          ip: '192.168.2.253',
          port: '',
          addr: '',
        },
        {
          name: '6路电流源01',
          ip: '192.168.2.253',
          port: '',
          addr: '',
        },
        {
          name: '6路电流源02',
          ip: '192.168.2.252',
          port: '',
          addr: '',
        },
        {
          name: '6路电流源03',
          ip: '192.168.2.252',
          port: '',
          addr: '',
        },
        {
          name: '6路电流源04',
          ip: '192.168.2.252',
          port: '',
          addr: '',
        },
      ],
      formTableData: [
        {
          name: '从板01(闭)',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '从板02(开)',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '从板03(开)',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '表位处理板',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '从板01(闭)',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '从板02(闭)',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '从板03(开)',
          ip: '',
          port: '',
          can: '',
        },
        // {
        //   name: '从板04(开)',
        //   ip: '',
        //   port: '',
        //   can: '',
        // },
        {
          name: '从板01(闭)',
          ip: '',
          port: '',
          can: '',
        },
        {
          name: '从板02(开)',
          ip: '',
          port: '',
          can: '',
        },
      ],
      measureTableData: [
        {
          name: '测量板01',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板02',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板03',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板05',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板06',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板07',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板08',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板09',
          ip: '',
          port: '',
          addr: '',
        },
        {
          name: '测量板10',
          ip: '',
          port: '',
          addr: '',
        },
      ],
      meterTableData: [
        {
          name: '电能表01',
          ip: '192.168.0.253',
          port: '',
          addr: '01',
        },
        {
          name: '电能表02',
          ip: '192.168.0.253',
          port: '',
          addr: '02',
        },
        {
          name: '电能表03',
          ip: '192.168.0.253',
          port: '',
          addr: '',
        },
        {
          name: '电能表04',
          ip: '192.168.0.253',
          port: '',
          addr: '',
        },
      ],
      systemChangeNum: 0,
    }
  },
  actions: {
    // setTableIndex(data) {
    //   this.tableIndex = data
    // },
    setCurrentTableData(data) {
      this.currentTableData = this.faultDataList[data]
    },
  },
  persist: {
    enabled: true,
    encryptionKey: 'tableData',
    strategies: [
      {
        key: 'tableData',
        storage: sessionStorage,
      },
    ],
  },
})
